package com.david.mydemo.ctl_mybatis_plus.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.david.mydemo.ctl_es.model.HxttResponse;
import com.david.mydemo.ctl_mybatis_plus.model.ProjectModel;
import com.david.mydemo.ctl_mybatis_plus.model.ProjectSearchModel;
import com.david.mydemo.ctl_mybatis_plus.service.IProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/project")
public class ProjectController {

    @Autowired
    private IProjectService projectService;


    /**
     * 分页查询项目信息列表-plus
     *
     * @param model
     * @return
     */
    @PostMapping("/selectProjectPagePlus")
    public HxttResponse selectProjectPagePlus(@RequestBody ProjectSearchModel model) {
        IPage<ProjectModel> pageInfo = projectService.selectProjectPagePlus(model);
        return new HxttResponse().success(pageInfo);
    }

    /**
     * 查询项目信息列表
     *
     * @return
     */
    @PostMapping("/selectProjectList")
    public HxttResponse selectProjectList() {
        List<ProjectModel> list = projectService.list();
        return new HxttResponse().success(list);
    }

    /**
     * 获取项目信息
     *
     * @param model
     * @return
     */
    @PostMapping("/getProject")
    public HxttResponse getProject(@RequestBody ProjectSearchModel model) {
        ProjectModel project = projectService.getById(model.getId());
        return new HxttResponse().success(project);
    }

}
